{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><div></div><div></div><div><strong>Installed Packages</strong><ul><li><span>ScottPlot, 5.0.55</span></li></ul></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "Loading extensions from `C:\\Users\\123\\.nuget\\packages\\skiasharp\\2.88.9\\interactive-extensions\\dotnet\\SkiaSharp.DotNet.Interactive.dll`"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# r\"G:\\2026\\HawtC2\\publish\\Release\\net9.0\\HawtC2.dll\"\n",
    "#r \"nuget:ScottPlot, 5.*\"\n",
    "//# r\"C:\\Users\\123\\.nuget\\packages\\skiasharp\\2.88.8\\interactive-extensions\\dotnet\\SkiaSharp.DotNet.Interactive.dll\"\n",
    "\n",
    "using OpenWECD.IO.Log;\n",
    "using MathNet.Numerics.LinearAlgebra;\n",
    "using OpenWECD.IO.math;\n",
    "using OpenWECD.IO.Numerics;\n",
    "using System.Collections.Generic;\n",
    "using System.Linq;\n",
    "using System.IO;\n",
    "using static OpenWECD.IO.math.LinearAlgebraHelper;\n",
    "using static System.Math;\n",
    "using OpenWECD.FEML;\n",
    "using ScottPlot;\n",
    "using OpenWECD.IO.IO;\n",
    "\n",
    "// Setup a custom formatter to display plots as images\n",
    "using Microsoft.DotNet.Interactive.Formatting;\n",
    "Formatter.Register(typeof(ScottPlot.Plot), (p, w) => \n",
    "    w.Write(((ScottPlot.Plot)p).GetPngHtml(800, 400)), HtmlFormatter.MimeType);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. 模块输出的代码生成器(持续维护更新)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "//# 设置OutputParList.xlsx路径并打开\n",
    "var excle=new OpenWECD.IO.IO.MSExcle(@\"G:\\2026\\HawtC2\\OutputParList_2.0.005.xlsx\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.1 创建必要函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "\n",
    "public static void writesummary(OpenWECD.IO.IO.OutFile file, string text)\n",
    "{\n",
    "    file.WriteLine(\"        /// <summary>\");\n",
    "    file.WriteLine($\"        /// {text}\");\n",
    "    file.WriteLine(\"        /// </summary>\");\n",
    "}\n",
    "//# 向文件当中写入title\n",
    "public static string[] title=new string[]\n",
    "{\n",
    "\"//**********************************************************************************************************************************\",\n",
    "\"// LICENSING\",\n",
    "\"// Copyright(C) 2021, 2025  TG Team,Key Laboratory of Jiangsu province High-Tech design of wind turbine,WTG,WL,ZZZ\",\n",
    "\"//  \",\n",
    "\"//    This file is part of OpenWECD.HawtC.APIL by 赵子祯, 2021, 2025\",\n",
    "\"// \",\n",
    "\"// Licensed under the Boost Software License - Version 1.0 - August 17th, 2003\",\n",
    "\"// you may not use this file except in compliance with the License.\",\n",
    "\"// You may obtain a copy of the License at\",\n",
    "\"// \",\n",
    "\"//     http://www.HawtC.cn/licenses.txt\",\n",
    "\"// \",\n",
    "\"// THE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\",\n",
    "\"// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\",\n",
    "\"// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT\",\n",
    "\"// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE\",\n",
    "\"// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,\",\n",
    "\"// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\",\n",
    "\"// DEALINGS IN THE SOFTWARE.\",\n",
    "\"// 该代码由赵子祯编写的代码生成器生成,不可擅自修改!任何bug请联系赵子祯 1821216780@qq.com\",\n",
    "\"//**********************************************************************************************************************************\"\n",
    "};\n",
    "\n",
    "public static void writeinf(OpenWECD.IO.IO.OutFile file, string text=\"\")\n",
    "{\n",
    "    var tilte=LinearAlgebraHelper.Copy(title);\n",
    "    if(text!=\"\")\n",
    "    {\n",
    "        tilte[4]=$\"//    This file is part of OpenWECD.HawtC.{text} by 赵子祯, 2021, 2025\";\n",
    "    }\n",
    "    file.WriteLine(tilte);\n",
    "}\n",
    "// def writeo(file,str,length):\n",
    "//     lens=len(str)\n",
    "//     num=length-lens\n",
    "//     if(num>0):\n",
    "//         for i in range(num):\n",
    "// str=str+\" \"\n",
    "//     file.write(str)\n",
    "public static void writeo(OpenWECD.IO.IO.OutFile file, string str, int length)\n",
    "{\n",
    "    var lens=str.Length;\n",
    "    var num=length-lens;\n",
    "    if(num>0)\n",
    "    {\n",
    "        for(int i=0;i<num;i++)\n",
    "        {\n",
    "str=str+\" \";\n",
    "        }\n",
    "    }\n",
    "    file.Write(str,\"\");\n",
    "}\n",
    "\n",
    "\n",
    "public static (\n",
    "    List<string> aname,\n",
    "    List<string> name, \n",
    "    List<string> namep, \n",
    "   List<string> unit,\n",
    "   List<int> channel, \n",
    "    List<string> description,\n",
    "    List<string> convention,\n",
    "    List<string> index,\n",
    "    List<string> ipx,\n",
    "    List<string> Category,\n",
    "    List<string> Titlechannel,\n",
    "    List<string> TitlechannelDisp\n",
    "   ) getsheetdata(string sheetname,OpenWECD.IO.IO.MSExcle excle)\n",
    "{\n",
    "    \n",
    "    //# 处理数据\n",
    "    List<string> fredata = new List<string>();\n",
    "    List<string> data = new List<string>();\n",
    "    List<string> indetie = new List<string>();\n",
    "    List<string> unit = new List<string>();\n",
    "    List<int> channel = new List<int>();\n",
    "    List<string> description = new List<string>();\n",
    "    List<string> convention = new List<string>();\n",
    "    List<string> index = new List<string>();\n",
    "    List<string> ipx = new List<string>();\n",
    "    List<string> Category = new List<string>();\n",
    "    List<string> Titlechannel = new List<string>();\n",
    "    List<string> TitlechannelDisp = new List<string>();\n",
    "    //# 获取当前表格有效行数\n",
    "    var sheet=excle.GetSheet(sheetname);\n",
    "int row=excle.RowCount(sheet);\n",
    "for (int i=1;i<row;i++)\n",
    "{\n",
    "    string dataTemp=sheet.RCellValue<string>(i,1).Trim();\n",
    "    string dataTemp1=sheet.RCellValue<string>(i,0).Trim();\n",
    "    if(dataTemp1!=string.Empty)\n",
    "    {\n",
    "        Category.Add(dataTemp1.Replace(\"/\",\"And\").Replace(\" \",\"_\").Replace(\"-\",\"_\").Replace(\"__\",\"_\"));\n",
    "        Titlechannel.Add(dataTemp1=sheet.RCellValue<int>(i,7).ToString());\n",
    "        TitlechannelDisp.Add(dataTemp1=sheet.RCellValue<string>(i,3));\n",
    "    }\n",
    "    if(dataTemp!=string.Empty)\n",
    "    {\n",
    "        \n",
    "        data.Add(dataTemp.Trim());\n",
    "        fredata.Add(dataTemp.Trim());\n",
    "        indetie.Add(dataTemp.Trim());\n",
    "        unit.Add(sheet.RCellValue<string>(i,5).Trim());//Units\n",
    "        channel.Add( sheet.RCellValue<int>(i,7));//Convert.ToInt32(row[\"输出频道编号\"])\n",
    "        description.Add( sheet.RCellValue<string>(i,3).Trim());//\"Description\"\n",
    "        convention.Add(sheet.RCellValue<string>(i,4).Trim());//\"Convention\n",
    "        string str1 = sheet.RCellValue<string>(i,8).Trim() as string ?? string.Empty;//\"截面编号\"\n",
    "        string str2 = sheet.RCellValue<string>(i,9).Trim() as string ?? string.Empty;//\"数量编号\"\n",
    "        string str3 = sheet.RCellValue<string>(i,10).Trim() as string ?? string.Empty;//\"其他编号\"\n",
    "        string strres = string.Empty;\n",
    "        string strres2 = string.Empty;\n",
    "\n",
    "        if (!string.IsNullOrEmpty(str1) && string.IsNullOrEmpty(str2) && string.IsNullOrEmpty(str3))\n",
    "        {\n",
    "strres = $\"[{str1}]\";\n",
    "strres2 = \"[]\";\n",
    "        }\n",
    "        else if (string.IsNullOrEmpty(str1) && !string.IsNullOrEmpty(str2) && string.IsNullOrEmpty(str3))\n",
    "        {\n",
    "strres = $\"[{str2}]\";\n",
    "strres2 = \"[]\";\n",
    "        }\n",
    "        else if (string.IsNullOrEmpty(str1) && string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3))\n",
    "        {\n",
    "strres = $\"[{str3}]\";\n",
    "strres2 = \"[]\";\n",
    "        }\n",
    "         else if (!string.IsNullOrEmpty(str1) && !string.IsNullOrEmpty(str2) && string.IsNullOrEmpty(str3))\n",
    "        {\n",
    "strres = $\"[{str1},{str2}]\";\n",
    "strres2 = \"[,]\";\n",
    "        }\n",
    "        else if (!string.IsNullOrEmpty(str1) && string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3))\n",
    "        {\n",
    "strres = $\"[{str1},{str3}]\";\n",
    "strres2 = \"[,]\";\n",
    "        }\n",
    "        else if (string.IsNullOrEmpty(str1) && !string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3))\n",
    "        {\n",
    "strres = $\"[{str2},{str3}]\";\n",
    "strres2 = \"[,]\";\n",
    "        }\n",
    "        else if (!string.IsNullOrEmpty(str1) && !string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3))\n",
    "        {\n",
    "strres = $\"[{str1},{str2},{str3}]\";\n",
    "strres2 = \"[,,]\";\n",
    "        }\n",
    "\n",
    "        index.Add(strres);\n",
    "        ipx.Add(strres2);\n",
    "    }\n",
    "\n",
    "    //# 查找是否有其他名字\n",
    "    string otherNames = sheet.RCellValue<string>(i,2).Trim();\n",
    "    if (!string.IsNullOrEmpty(otherNames))\n",
    "    {\n",
    "        string[] otherNameArray = otherNames.Split(',').RemoveNull();\n",
    "        foreach (string otherName in otherNameArray)\n",
    "        {\n",
    "data.Add(otherName.Trim());\n",
    "indetie.Add(dataTemp.Trim());\n",
    "\n",
    "unit.Add(sheet.RCellValue<string>(i,5).Trim());//Units\n",
    "channel.Add( sheet.RCellValue<int>(i,7));//Convert.ToInt32(row[\"输出频道编号\"])\n",
    "description.Add( sheet.RCellValue<string>(i,3).Trim());//\"Description\"\n",
    "convention.Add(sheet.RCellValue<string>(i,4).Trim());//\"Convention\n",
    "\n",
    "string str1 = sheet.RCellValue<string>(i,8).Trim() as string ?? string.Empty;//\"截面编号\"\n",
    "string str2 = sheet.RCellValue<string>(i,9).Trim() as string ?? string.Empty;//\"数量编号\"\n",
    "string str3 = sheet.RCellValue<string>(i,10).Trim() as string ?? string.Empty;//\"其他编号\"\n",
    "string strres = string.Empty;\n",
    "string strres2 = string.Empty;\n",
    "\n",
    "if (!string.IsNullOrEmpty(str1) && string.IsNullOrEmpty(str2) && string.IsNullOrEmpty(str3))\n",
    "{\n",
    "    strres = $\"[{str1}]\";\n",
    "    strres2 = \"[]\";\n",
    "}\n",
    "else if (string.IsNullOrEmpty(str1) && !string.IsNullOrEmpty(str2) && string.IsNullOrEmpty(str3))\n",
    "{\n",
    "    strres = $\"[{str2}]\";\n",
    "    strres2 = \"[]\";\n",
    "}\n",
    "else if (string.IsNullOrEmpty(str1) && string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3))\n",
    "{\n",
    "    strres = $\"[{str3}]\";\n",
    "    strres2 = \"[]\";\n",
    "}\n",
    "else if (!string.IsNullOrEmpty(str1) && !string.IsNullOrEmpty(str2) && string.IsNullOrEmpty(str3))\n",
    "{\n",
    "    strres = $\"[{str1},{str2}]\";\n",
    "    strres2 = \"[,]\";\n",
    "}\n",
    "else if (!string.IsNullOrEmpty(str1) && string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3))\n",
    "{\n",
    "    strres = $\"[{str1},{str3}]\";\n",
    "    strres2 = \"[,]\";\n",
    "}\n",
    "else if (string.IsNullOrEmpty(str1) && !string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3))\n",
    "{\n",
    "    strres = $\"[{str2},{str3}]\";\n",
    "    strres2 = \"[,]\";\n",
    "}\n",
    "else if (!string.IsNullOrEmpty(str1) && !string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3))\n",
    "{\n",
    "    strres = $\"[{str1},{str2},{str3}]\";\n",
    "    strres2 = \"[,,]\";\n",
    "}\n",
    "\n",
    "\n",
    "index.Add(strres);\n",
    "ipx.Add(strres2);\n",
    "        }\n",
    "    }\n",
    "}\n",
    "return (fredata,data,indetie,unit,channel,description,convention,index,ipx,Category,Titlechannel,TitlechannelDisp);\n",
    "\n",
    "}\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.2 MBD模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "LogHelper.DisplayInformation();\n",
    "//# 设置代码路径\n",
    "string ApiL_OutputParamFilePath=@\"G:\\2026\\HawtC2\\modules\\MBD\\MBD_OutputParam.cs\";\n",
    "\n",
    "//# 获取对应表格数据\n",
    "var sheet=excle.GetSheet(\"MBD\");\n",
    "//# 初始化文件读写生成器\n",
    "var file=new OpenWECD.IO.IO.OutFile(ApiL_OutputParamFilePath);\n",
    "\n",
    "//# \n",
    "(var adata,var data,var namep,var unit,var channel,var description,var convention,var index,var ipx,var Category,var TitleChannel)=getsheetdata(\"MBD\",excle);\n",
    "//# 输出信息\n",
    "file.WriteLine($\"//! 自动生成 MBD 多体动力学的有效输出变量数量为:{data.Count}\");\n",
    "//# 写入文件头\n",
    "writeinf(file,\"MBDL\");\n",
    "\n",
    "\n",
    "file.WriteLine(\"using System.Collections.Generic;\",\"using System.Collections.Frozen;\",\"using OpenWECD.IO.Log;\",\"using MathNet.Numerics.LinearAlgebra;\",\n",
    "   \"using OpenWECD.IO.Interface1;\");\n",
    "\n",
    "//#写入命名空间\n",
    "file.WriteLine(\"namespace OpenWECD.MBD\");\n",
    "file.WriteLine(\"{\");\n",
    "writesummary(file,\"MBD输出参数类\");\n",
    "file.WriteLine(\"    public class MBD_OutputParam\");\n",
    "file.WriteLine(\"    {\");\n",
    "\n",
    "\n",
    "//! 写入输出参数的单位参数表\n",
    "writesummary(file,\"输出参数的参数表,用来保存变量和单位信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, string> MBD_OutParUnit = new Dictionary<string, string>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, unit[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "//# 输出参数的通道表,用来保存变量和通道信息\n",
    "writesummary(file,\"输出参数的通道表,用来保存变量和通道信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> MBD_OutParChannel = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, channel[i].ToString(), 10);\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "\n",
    "//# 输出参数的描述表,用来保存变量和描述信息\n",
    "writesummary(file,\"输出参数的维度 0 表示没有维度 1 表示只要部件编号 2 表示只要部件截面 3 表示部件编号和截面编号都要\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> MBD_OutParDim = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    if(index[i]==string.Empty)\n",
    "    {\n",
    "        file.Write(\"0\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[K]\")\n",
    "    {\n",
    "        file.Write(\"1\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J]\")\n",
    "    {\n",
    "        file.Write(\"2\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J,K]\")\n",
    "    {\n",
    "        file.Write(\"3\",\"\");\n",
    "    }\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "writesummary(file,\"依据变量名称,输出变量值\");\n",
    "file.WriteLine(\"        public static double MBD_GetParamOutput(string param, int J, MBD_AllOuts AllOuts,int K=0)\");\n",
    "file.WriteLine(\"        {\");\n",
    "file.WriteLine(\"            switch (param)\");\n",
    "file.WriteLine(\"            {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"                case \",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file,data[i],10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.WriteLine(\":\");\n",
    "    file.Write(\"                    return AllOuts.\",\"\");\n",
    "    file.Write(namep[i],\"\");\n",
    "    file.Write(index[i],\"\");\n",
    "    file.WriteLine(\";\");\n",
    "\n",
    "\n",
    "}\n",
    "    file.WriteLine(\"\");\n",
    "    file.WriteLine(\"                default:\");\n",
    "    file.WriteLine(\"                    LogHelper.ErrorLog($\\\"{param} not Support!,Please Visit OutputParList or www.openwecd.fun \\\",FunctionName: \\\"MBD_GetParamOutput\\\");\");\n",
    "    file.WriteLine(\"                    return 0;\");\n",
    "file.WriteLine(\"            }\");\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "\n",
    "//# 输出变量结构体\n",
    "writesummary(file,\"阐述变量的结构体\");\n",
    "file.WriteLine(\"        public struct MBD_AllOutss\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.WriteLine(\"            /// <summary>\");\n",
    "    file.WriteLine($\"            /// {description[i]}  {convention[i]}\"+$\" unit:{unit[i]}\");\n",
    "    file.WriteLine(\"            /// </summary>\");\n",
    "        file.Write(\"            public double \",\"\");\n",
    "        file.Write(ipx[i]+\" \",\"\");\n",
    "        file.Write(data[i],\"\");\n",
    "        file.WriteLine(\";\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "//# 输出频道枚举\n",
    "writesummary(file,\"载荷输出的通道枚举体,要和c#自动化文件对应\");\n",
    "file.WriteLine(\"        [SourceReflection]\");\n",
    "file.WriteLine(\"        public enum MBD_Loadchannels\");\n",
    "file.WriteLine(\"        {\");\n",
    "for(int i=0;i<Category.Count;i++)\n",
    "{\n",
    "    file.WriteLine($\"            {Category[i]} = {TitleChannel[i]},\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "\n",
    "file.Outfinish(); "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.3 MoptL 模块"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.4 APIL_hawtc.APi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "\n",
    "LogHelper.DisplayInformation();\n",
    "//# 设置代码路径\n",
    "string ApiL_OutputParamFilePath=@\"G:\\2026\\OpenhastV7\\modules\\APIL\\\\ApiL_OutputParam.cs\";\n",
    "\n",
    "\n",
    "var sheet=excle.GetSheet(\"MoptKeyType\");\n",
    "\n",
    "//# 初始化文件读写生成器\n",
    "var file=new OpenWECD.IO.IO.OutFile(ApiL_OutputParamFilePath);\n",
    "\n",
    "//# 获取当前表格有效行数\n",
    "int row=excle.RowCount(sheet);\n",
    "\n",
    "\n",
    "file.WriteLine(\"\");\n",
    "writeinf(file,\"APIL\");\n",
    "file.WriteLine(\"\");\n",
    "file.WriteLine(\"using OpenWECD.IO.IO;\",\"using OpenWECD.IO.Log;\",\"using System;\",\"using System.Collections.Frozen;\"\n",
    ",\"using System.Collections.Generic;\",\"using System.Linq;\",\"using System.Reflection;\");\n",
    "file.WriteLine(\"\");\n",
    "file.WriteLine(\"namespace OpenWECD.APIL\");\n",
    "file.WriteLine(\"{\");\n",
    "file.WriteLine(\"    /// <summary>\",\"    /// API函数当中的参数表\",\"    /// </summary>\");\n",
    "file.WriteLine(\"    public class ApiL_OutputParam\");\n",
    "file.WriteLine(\"    {\");\n",
    "file.WriteLine(\"        /// <summary>\",\"        /// 构造函数,初始化API当中的参数表\",\"        /// </summary>\");\n",
    "file.WriteLine(\"        public ApiL_OutputParam()\");\n",
    "file.WriteLine(\"        {\");\n",
    "file.WriteLine(\"//#对ApiYamlNameAndTypeDictionary进行初始化\");\n",
    "file.WriteLine(\"var ApiYamlNameAndTypeDictionarytemp = new Dictionary<string, Type>();\");\n",
    "file.WriteLine(\"foreach (var item in ApiYamlNameAndTypeNameDictionary)\");\n",
    "file.WriteLine(\"{\");\n",
    "file.WriteLine(\"    Type res = Type.GetType(item.Value);\");\n",
    "file.WriteLine(\"    if (res == null)\");\n",
    "file.WriteLine(\"    {\");\n",
    "file.WriteLine(\"        if (item.Value.Contains(\\\"OpenWECD\\\"))//是枚举，单独来看\");\n",
    "file.WriteLine(\"        {\");\n",
    "file.WriteLine(\"Assembly assembly = Assembly.Load(Otherhelper.GetCurrentProjectName());\");\n",
    "file.WriteLine(\"res = assembly.GetType(item.Value);\");\n",
    "file.WriteLine(\"        }\");\n",
    "file.WriteLine(\"        if (res == null)\");\n",
    "file.WriteLine(\"        {\");\n",
    "file.WriteLine(\"LogHelper.WarnLog(item.Key+ \\\"INI ERROR \\\",FunctionName: \\\"ApiL_OutputParam\\\");\");\n",
    "file.WriteLine(\"        }\");\n",
    "file.WriteLine(\"    }\");\n",
    "\n",
    "file.WriteLine(\"    //if(!TypeList.Contains(res))\");\n",
    "file.WriteLine(\"    //{\");\n",
    "file.WriteLine(\"    //    TypeList.Add(res);\");\n",
    "file.WriteLine(\"    //}\");\n",
    "file.WriteLine(\"\");\n",
    "file.WriteLine(\"    ApiYamlNameAndTypeDictionarytemp.Add(item.Key, res);\");\n",
    "file.WriteLine(\"}\");\n",
    "file.WriteLine(\"ApiYamlNameAndTypeDictionary = ApiYamlNameAndTypeDictionarytemp.ToFrozenDictionary();\");\n",
    "file.WriteLine(\"TypeList = ApiYamlNameAndTypeDictionary.Values.Distinct().ToArray();\");\n",
    "file.WriteLine(\"        }\");\n",
    "file.WriteLine(\"\");\n",
    "\n",
    "file.WriteLine(\"        /// <summary>\",\"        /// 输出参数的参数表,用来保存yaml变量和类型和名称信息\",\"        /// </summary>\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, string> ApiYamlNameAndTypeNameDictionary = new Dictionary<string, string>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for(int i=1;i<row;i++)\n",
    "{\n",
    "    file.WriteLine(\"{\\\"\"+sheet.RCellValue<string>(i,0)+\"\\\",\\\"\"+sheet.RCellValue<string>(i,1)+\"\\\"},\");\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "\n",
    "//# 输出参数的参数表,pst APi 当中变量名称及其对应模块的名称\n",
    "file.WriteLine(\"        /// <summary>\",\"        /// pst APi 当中变量名称及其对应模块的名称\",\"        /// </summary>\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, string> ApiOutNameAndMoudleNameDirtionary = new Dictionary<string, string>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "//# 首先处理AeroL\n",
    "for(int i=0;i<OpenWECD.AeroL.AeroL_OutputParam.AER_OutParChannel.Keys.Count();i++)\n",
    "{\n",
    "    file.WriteLine(\"{\\\"\"+OpenWECD.AeroL.AeroL_OutputParam.AER_OutParUnit.Keys[i]+\"\\\",\\\"\"+\"AeroL\"+\"\\\"},\");\n",
    "}\n",
    "\n",
    "\n",
    "//# 再处理MBDL\n",
    "for(int i=0;i<OpenWECD.MBD.MBD_OutputParam.MBD_OutParChannel.Keys.Count();i++)\n",
    "{\n",
    "    file.WriteLine(\"{\\\"\"+OpenWECD.MBD.MBD_OutputParam.MBD_OutParChannel.Keys[i]+\"\\\",\\\"\"+\"MBDL\"+\"\\\"},\");\n",
    "}\n",
    "\n",
    "\n",
    "//# 再处理WINDL\n",
    "for(int i=0;i<OpenWECD.WindL.WindL_OutputParam.WND_OutParChannel.Keys.Count();i++)\n",
    "{\n",
    "    file.WriteLine(\"{\\\"\"+OpenWECD.WindL.WindL_OutputParam.WND_OutParUnit.Keys.ToArray()[i]+\"\\\",\\\"\"+\"WindL\"+\"\\\"},\");\n",
    "}\n",
    "\n",
    "//# 再处理ControL\n",
    "for(int i=0;i<OpenWECD.ControlL.ControL_OutputParam.CON_OutParChannel.Keys.Count();i++)\n",
    "{\n",
    "    file.WriteLine(\"{\\\"\"+OpenWECD.ControlL.ControL_OutputParam.CON_OutParChannel.Keys.ToArray()[i]+\"\\\",\\\"\"+\"ControL\"+\"\\\"},\");\n",
    "}\n",
    "\n",
    "\n",
    "\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "file.WriteLine(\"\");\n",
    "file.WriteLine(\"        /// <summary>\",\"        /// 输出参数的参数表,用来保存yam变量和类型信息\",\"        /// </summary>\");\n",
    "file.WriteLine(\"        public  FrozenDictionary<string, Type> ApiYamlNameAndTypeDictionary;\");\n",
    "file.WriteLine(\"        /// <summary>\",\"        /// 保存了全部的类型种类信息，没有重复！\",\"        /// </summary>\");\n",
    "file.WriteLine(\"        public Type[] TypeList;\");\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "sheet.RCellValue<string>(0,1);\n",
    "\n",
    "file.Outfinish();\n",
    "typeof(OpenWECD.AeroL.AeroL_Loadchannels)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.5 AeroL 模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "LogHelper.DisplayInformation();\n",
    "//# 设置代码路径\n",
    "string ApiL_OutputParamFilePath=@\"G:\\2026\\HawtC2\\modules\\AeroL\\AeroL_OutputParam.cs\";\n",
    "\n",
    "//# 获取对应表格数据\n",
    "var sheet=excle.GetSheet(\"AeroL\");\n",
    "//# 初始化文件读写生成器\n",
    "var file=new OpenWECD.IO.IO.OutFile(ApiL_OutputParamFilePath);\n",
    "\n",
    "//# \n",
    "(var adata,var data,var namep,var unit,var channel,var description,var convention,var index,var ipx,var Category,var TitleChannel)=getsheetdata(\"AeroL\",excle);\n",
    "//# 输出信息\n",
    "file.WriteLine($\"//! 自动生成 AeroL 非定常与定常空气动力学模块的有效输出变量数量为:{data.Count}\");\n",
    "//# 写入文件头\n",
    "writeinf(file,\"AeroL_OutputParam\");\n",
    "\n",
    "\n",
    "file.WriteLine(\"using System.Collections.Generic;\",\"using System.Collections.Frozen;\",\"using OpenWECD.IO.Log;\",\"using MathNet.Numerics.LinearAlgebra;\",\n",
    "   \"using OpenWECD.IO.Interface1;\");\n",
    "\n",
    "//#写入命名空间\n",
    "file.WriteLine(\"namespace OpenWECD.AeroL\");\n",
    "file.WriteLine(\"{\");\n",
    "writesummary(file,\"MBD输出参数类\");\n",
    "file.WriteLine(\"    public class AeroL_OutputParam\");\n",
    "file.WriteLine(\"    {\");\n",
    "\n",
    "\n",
    "//! 写入输出参数的单位参数表\n",
    "writesummary(file,\"输出参数的参数表,用来保存变量和单位信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, string> AER_OutParUnit = new Dictionary<string, string>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, unit[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "//# 输出参数的通道表,用来保存变量和通道信息\n",
    "writesummary(file,\"输出参数的通道表,用来保存变量和通道信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> AER_OutParChannel = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, channel[i].ToString(), 10);\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "\n",
    "//# 输出参数的描述表,用来保存变量和描述信息\n",
    "writesummary(file,\"输出参数的维度 0 表示没有维度 1 表示只要部件编号 2 表示只要部件截面 3 表示部件编号和截面编号都要\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> AER_OutParDim = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    if(index[i]==string.Empty)\n",
    "    {\n",
    "        file.Write(\"0\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[K]\")\n",
    "    {\n",
    "        file.Write(\"1\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J]\")\n",
    "    {\n",
    "        file.Write(\"2\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J,K]\")\n",
    "    {\n",
    "        file.Write(\"3\",\"\");\n",
    "    }\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "writesummary(file,\"依据变量名称,输出变量值\");\n",
    "file.WriteLine(\"        public static double AER_GetParamOutput(string param, int J, AER_AllOuts AllOuts,int K=0)\");\n",
    "file.WriteLine(\"        {\");\n",
    "file.WriteLine(\"            switch (param)\");\n",
    "file.WriteLine(\"            {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"                case \",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file,data[i],10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.WriteLine(\":\");\n",
    "    file.Write(\"                    return AllOuts.\",\"\");\n",
    "    file.Write(namep[i],\"\");\n",
    "    file.Write(index[i],\"\");\n",
    "    file.WriteLine(\";\");\n",
    "\n",
    "\n",
    "}\n",
    "    file.WriteLine(\"\");\n",
    "    file.WriteLine(\"                default:\");\n",
    "    file.WriteLine(\"                    LogHelper.ErrorLog($\\\"{param} not Support!,Please Visit OutputParList or www.openwecd.fun \\\",FunctionName: \\\"MBD_GetParamOutput\\\");\");\n",
    "    file.WriteLine(\"                    return 0;\");\n",
    "file.WriteLine(\"            }\");\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "\n",
    "//# 输出变量结构体\n",
    "writesummary(file,\"阐述变量的结构体\");\n",
    "file.WriteLine(\"        public struct AER_AllOutss\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.WriteLine(\"            /// <summary>\");\n",
    "    file.WriteLine($\"            /// {description[i]}  {convention[i]}\"+$\" unit:{unit[i]}\");\n",
    "    file.WriteLine(\"            /// </summary>\");\n",
    "        file.Write(\"            public double \",\"\");\n",
    "        file.Write(ipx[i]+\" \",\"\");\n",
    "        file.Write(data[i],\"\");\n",
    "        file.WriteLine(\";\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "//# 输出频道枚举\n",
    "writesummary(file,\"载荷输出的通道枚举体,要和c#自动化文件对应\");\n",
    "file.WriteLine(\"        [SourceReflection]\");\n",
    "file.WriteLine(\"        public enum AER_Loadchannels\");\n",
    "file.WriteLine(\"        {\");\n",
    "for(int i=0;i<Category.Count;i++)\n",
    "{\n",
    "    file.WriteLine($\"            {Category[i]} = {TitleChannel[i]},\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "\n",
    "file.Outfinish(); "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.6 BeamL 模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "LogHelper.DisplayInformation();\n",
    "//# 设置代码路径\n",
    "string ApiL_OutputParamFilePath=@\"G:\\2026\\OpenhastV7\\modules\\BeamL/BeamL_OutputParam.cs\";\n",
    "\n",
    "//# 获取对应表格数据\n",
    "var sheet=excle.GetSheet(\"BeamL\");\n",
    "//# 初始化文件读写生成器\n",
    "var file=new OpenWECD.IO.IO.OutFile(ApiL_OutputParamFilePath);\n",
    "\n",
    "//# \n",
    "(var adata,var data,var namep,var unit,var channel,var description,var convention,var index,var ipx,var Category,var TitleChannel)=getsheetdata(\"BeamL\",excle);\n",
    "//# 输出信息\n",
    "file.WriteLine($\"//! 自动生成 BeamL 非线性与线性各向异性梁模块的有效输出变量数量为:{data.Count}\");\n",
    "//# 写入文件头\n",
    "writeinf(file,\"BeamL_OutputParam\");\n",
    "\n",
    "\n",
    "file.WriteLine(\"using System.Collections.Generic;\",\"using System.Collections.Frozen;\",\"using OpenWECD.IO.Log;\",\"using MathNet.Numerics.LinearAlgebra;\",\n",
    "   \"using OpenWECD.IO.Interface1;\");\n",
    "\n",
    "//#写入命名空间\n",
    "file.WriteLine(\"namespace OpenWECD.BeamL\");\n",
    "file.WriteLine(\"{\");\n",
    "writesummary(file,\"MBD输出参数类\");\n",
    "file.WriteLine(\"    public class BeamL_OutputParam\");\n",
    "file.WriteLine(\"    {\");\n",
    "\n",
    "\n",
    "//! 写入输出参数的单位参数表\n",
    "writesummary(file,\"输出参数的参数表,用来保存变量和单位信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, string> BEA_OutParUnit = new Dictionary<string, string>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, unit[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "//# 输出参数的通道表,用来保存变量和通道信息\n",
    "writesummary(file,\"输出参数的通道表,用来保存变量和通道信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> BEA_OutParChannel = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, channel[i].ToString(), 10);\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "\n",
    "//# 输出参数的描述表,用来保存变量和描述信息\n",
    "writesummary(file,\"输出参数的维度 0 表示没有维度 1 表示只要部件编号 2 表示只要部件截面 3 表示部件编号和截面编号都要\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> BEA_OutParDim = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    if(index[i]==string.Empty)\n",
    "    {\n",
    "        file.Write(\"0\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[K]\")\n",
    "    {\n",
    "        file.Write(\"1\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J]\")\n",
    "    {\n",
    "        file.Write(\"2\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J,K]\")\n",
    "    {\n",
    "        file.Write(\"3\",\"\");\n",
    "    }\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "writesummary(file,\"依据变量名称,输出变量值\");\n",
    "file.WriteLine(\"        public static double BEA_GetParamOutput(string param, int J, BEA_AllOuts AllOuts,int K=0)\");\n",
    "file.WriteLine(\"        {\");\n",
    "file.WriteLine(\"            switch (param)\");\n",
    "file.WriteLine(\"            {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"                case \",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file,data[i],10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.WriteLine(\":\");\n",
    "    file.Write(\"                    return AllOuts.\",\"\");\n",
    "    file.Write(namep[i],\"\");\n",
    "    file.Write(index[i],\"\");\n",
    "    file.WriteLine(\";\");\n",
    "\n",
    "\n",
    "}\n",
    "    file.WriteLine(\"\");\n",
    "    file.WriteLine(\"                default:\");\n",
    "    file.WriteLine(\"                    LogHelper.ErrorLog($\\\"{param} not Support!,Please Visit OutputParList or www.openwecd.fun \\\",FunctionName: \\\"MBD_GetParamOutput\\\");\");\n",
    "    file.WriteLine(\"                    return 0;\");\n",
    "file.WriteLine(\"            }\");\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "\n",
    "//# 输出变量结构体\n",
    "writesummary(file,\"阐述变量的结构体\");\n",
    "file.WriteLine(\"        public struct BEA_AllOutss\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.WriteLine(\"            /// <summary>\");\n",
    "    file.WriteLine($\"            /// {description[i]}  {convention[i]}\"+$\" unit:{unit[i]}\");\n",
    "    file.WriteLine(\"            /// </summary>\");\n",
    "        file.Write(\"            public double \",\"\");\n",
    "        file.Write(ipx[i]+\" \",\"\");\n",
    "        file.Write(data[i],\"\");\n",
    "        file.WriteLine(\";\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "//# 输出频道枚举\n",
    "writesummary(file,\"载荷输出的通道枚举体,要和c#自动化文件对应\");\n",
    "file.WriteLine(\"        [SourceReflection]\");\n",
    "file.WriteLine(\"        public enum BEA_Loadchannels\");\n",
    "file.WriteLine(\"        {\");\n",
    "for(int i=0;i<Category.Count;i++)\n",
    "{\n",
    "    file.WriteLine($\"            {Category[i]} = {TitleChannel[i]},\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "\n",
    "file.Outfinish(); "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.7 ControL 模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "LogHelper.DisplayInformation();\n",
    "//# 设置代码路径\n",
    "string ApiL_OutputParamFilePath=@\"G:\\2026\\OpenhastV7\\modules\\ControlL\\ControL_OutputParam.cs\";\n",
    "\n",
    "//# 获取对应表格数据\n",
    "var sheet=excle.GetSheet(\"ControL\");\n",
    "//# 初始化文件读写生成器\n",
    "var file=new OpenWECD.IO.IO.OutFile(ApiL_OutputParamFilePath);\n",
    "\n",
    "//# \n",
    "(var adata,var data,var namep,var unit,var channel,var description,var convention,var index,var ipx,var Category,var TitleChannel)=getsheetdata(\"ControL\",excle);\n",
    "//# 输出信息\n",
    "file.WriteLine($\"//! 自动生成 ControL 控制器模块的有效输出变量数量为:{data.Count}\");\n",
    "//# 写入文件头\n",
    "writeinf(file,\"ControL_OutputParam\");\n",
    "\n",
    "\n",
    "file.WriteLine(\"using System.Collections.Generic;\",\"using System.Collections.Frozen;\",\"using OpenWECD.IO.Log;\",\"using MathNet.Numerics.LinearAlgebra;\",\n",
    "   \"using OpenWECD.IO.Interface1;\");\n",
    "\n",
    "//#写入命名空间\n",
    "file.WriteLine(\"namespace OpenWECD.ControlL\");\n",
    "file.WriteLine(\"{\");\n",
    "writesummary(file,\"MBD输出参数类\");\n",
    "file.WriteLine(\"    public class ControL_OutputParam\");\n",
    "file.WriteLine(\"    {\");\n",
    "\n",
    "\n",
    "//! 写入输出参数的单位参数表\n",
    "writesummary(file,\"输出参数的参数表,用来保存变量和单位信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, string> CON_OutParUnit = new Dictionary<string, string>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, unit[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "//# 输出参数的通道表,用来保存变量和通道信息\n",
    "writesummary(file,\"输出参数的通道表,用来保存变量和通道信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> CON_OutParChannel = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, channel[i].ToString(), 10);\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "\n",
    "//# 输出参数的描述表,用来保存变量和描述信息\n",
    "writesummary(file,\"输出参数的维度 0 表示没有维度 1 表示只要部件编号 2 表示只要部件截面 3 表示部件编号和截面编号都要\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> CON_OutParDim = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    if(index[i]==string.Empty)\n",
    "    {\n",
    "        file.Write(\"0\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[K]\")\n",
    "    {\n",
    "        file.Write(\"1\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J]\")\n",
    "    {\n",
    "        file.Write(\"2\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J,K]\")\n",
    "    {\n",
    "        file.Write(\"3\",\"\");\n",
    "    }\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "writesummary(file,\"依据变量名称,输出变量值\");\n",
    "file.WriteLine(\"        public static double CON_GetParamOutput(string param, int J, CON_AllOuts AllOuts,int K=0)\");\n",
    "file.WriteLine(\"        {\");\n",
    "file.WriteLine(\"            switch (param)\");\n",
    "file.WriteLine(\"            {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"                case \",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file,data[i],10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.WriteLine(\":\");\n",
    "    file.Write(\"                    return AllOuts.\",\"\");\n",
    "    file.Write(namep[i],\"\");\n",
    "    file.Write(index[i],\"\");\n",
    "    file.WriteLine(\";\");\n",
    "\n",
    "\n",
    "}\n",
    "    file.WriteLine(\"\");\n",
    "    file.WriteLine(\"                default:\");\n",
    "    file.WriteLine(\"                    LogHelper.ErrorLog($\\\"{param} not Support!,Please Visit OutputParList or www.openwecd.fun \\\",FunctionName: \\\"MBD_GetParamOutput\\\");\");\n",
    "    file.WriteLine(\"                    return 0;\");\n",
    "file.WriteLine(\"            }\");\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "\n",
    "//# 输出变量结构体\n",
    "writesummary(file,\"阐述变量的结构体\");\n",
    "file.WriteLine(\"        public struct CON_AllOutss\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.WriteLine(\"            /// <summary>\");\n",
    "    file.WriteLine($\"            /// {description[i]}  {convention[i]}\"+$\" unit:{unit[i]}\");\n",
    "    file.WriteLine(\"            /// </summary>\");\n",
    "        file.Write(\"            public double \",\"\");\n",
    "        file.Write(ipx[i]+\" \",\"\");\n",
    "        file.Write(data[i],\"\");\n",
    "        file.WriteLine(\";\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "//# 输出频道枚举\n",
    "writesummary(file,\"载荷输出的通道枚举体,要和c#自动化文件对应\");\n",
    "file.WriteLine(\"        [SourceReflection]\");\n",
    "file.WriteLine(\"        public enum BEA_Loadchannels\");\n",
    "file.WriteLine(\"        {\");\n",
    "for(int i=0;i<Category.Count;i++)\n",
    "{\n",
    "    file.WriteLine($\"            {Category[i]} = {TitleChannel[i]},\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "\n",
    "file.Outfinish(); "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.8 FEML 模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "LogHelper.DisplayInformation();\n",
    "//# 设置代码路径\n",
    "string ApiL_OutputParamFilePath=@\"G:\\2026\\OpenhastV7\\modules\\FEML\\FEM_OutputParam.cs\";\n",
    "\n",
    "//# 获取对应表格数据\n",
    "var sheet=excle.GetSheet(\"FEML\");\n",
    "//# 初始化文件读写生成器\n",
    "var file=new OpenWECD.IO.IO.OutFile(ApiL_OutputParamFilePath);\n",
    "\n",
    "//# \n",
    "(var adata,var data,var namep,var unit,var channel,var description,var convention,var index,var ipx,var Category,var TitleChannel)=getsheetdata(\"FEML\",excle);\n",
    "//# 输出信息\n",
    "file.WriteLine($\"//! 自动生成 FEML 有限元模块的有效输出变量数量为:{data.Count}\");\n",
    "//# 写入文件头\n",
    "writeinf(file,\"FEM_OutputParam\");\n",
    "\n",
    "\n",
    "file.WriteLine(\"using System.Collections.Generic;\",\"using System.Collections.Frozen;\",\"using OpenWECD.IO.Log;\",\"using MathNet.Numerics.LinearAlgebra;\",\n",
    "   \"using OpenWECD.IO.Interface1;\");\n",
    "\n",
    "//#写入命名空间\n",
    "file.WriteLine(\"namespace OpenWECD.FEML\");\n",
    "file.WriteLine(\"{\");\n",
    "writesummary(file,\"MBD输出参数类\");\n",
    "file.WriteLine(\"    public class FEM_OutputParam\");\n",
    "file.WriteLine(\"    {\");\n",
    "\n",
    "\n",
    "//! 写入输出参数的单位参数表\n",
    "writesummary(file,\"输出参数的参数表,用来保存变量和单位信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, string> FEM_OutParUnit = new Dictionary<string, string>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, unit[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "//# 输出参数的通道表,用来保存变量和通道信息\n",
    "writesummary(file,\"输出参数的通道表,用来保存变量和通道信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> FEM_OutParChannel = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, channel[i].ToString(), 10);\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "\n",
    "//# 输出参数的描述表,用来保存变量和描述信息\n",
    "writesummary(file,\"输出参数的维度 0 表示没有维度 1 表示只要部件编号 2 表示只要部件截面 3 表示部件编号和截面编号都要\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> FEM_OutParDim = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    if(index[i]==string.Empty)\n",
    "    {\n",
    "        file.Write(\"0\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[K]\")\n",
    "    {\n",
    "        file.Write(\"1\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J]\")\n",
    "    {\n",
    "        file.Write(\"2\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J,K]\")\n",
    "    {\n",
    "        file.Write(\"3\",\"\");\n",
    "    }\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "writesummary(file,\"依据变量名称,输出变量值\");\n",
    "file.WriteLine(\"        public static double FEM_GetParamOutput(string param, int J, FEM_AllOuts AllOuts,int K=0)\");\n",
    "file.WriteLine(\"        {\");\n",
    "file.WriteLine(\"            switch (param)\");\n",
    "file.WriteLine(\"            {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"                case \",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file,data[i],10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.WriteLine(\":\");\n",
    "    file.Write(\"                    return AllOuts.\",\"\");\n",
    "    file.Write(namep[i],\"\");\n",
    "    file.Write(index[i],\"\");\n",
    "    file.WriteLine(\";\");\n",
    "\n",
    "\n",
    "}\n",
    "    file.WriteLine(\"\");\n",
    "    file.WriteLine(\"                default:\");\n",
    "    file.WriteLine(\"                    LogHelper.ErrorLog($\\\"{param} not Support!,Please Visit OutputParList or www.openwecd.fun \\\",FunctionName: \\\"MBD_GetParamOutput\\\");\");\n",
    "    file.WriteLine(\"                    return 0;\");\n",
    "file.WriteLine(\"            }\");\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "\n",
    "//# 输出变量结构体\n",
    "writesummary(file,\"阐述变量的结构体\");\n",
    "file.WriteLine(\"        public struct FEM_AllOutss\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.WriteLine(\"            /// <summary>\");\n",
    "    file.WriteLine($\"            /// {description[i]}  {convention[i]}\"+$\" unit:{unit[i]}\");\n",
    "    file.WriteLine(\"            /// </summary>\");\n",
    "        file.Write(\"            public double \",\"\");\n",
    "        file.Write(ipx[i]+\" \",\"\");\n",
    "        file.Write(data[i],\"\");\n",
    "        file.WriteLine(\";\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "//# 输出频道枚举\n",
    "writesummary(file,\"载荷输出的通道枚举体,要和c#自动化文件对应\");\n",
    "file.WriteLine(\"        [SourceReflection]\");\n",
    "file.WriteLine(\"        public enum FEM_Loadchannels\");\n",
    "file.WriteLine(\"        {\");\n",
    "for(int i=0;i<Category.Count;i++)\n",
    "{\n",
    "    file.WriteLine($\"            {Category[i]} = {TitleChannel[i]},\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "\n",
    "file.Outfinish(); "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.9 WindL 模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "LogHelper.DisplayInformation();\n",
    "//# 设置代码路径\n",
    "string ApiL_OutputParamFilePath=@\"G:\\2026\\HawtC2\\modules\\WindL\\WindL_OutputParam.cs\";\n",
    "\n",
    "//# 获取对应表格数据\n",
    "var sheet=excle.GetSheet(\"WindL\");\n",
    "//# 初始化文件读写生成器\n",
    "var file=new OpenWECD.IO.IO.OutFile(ApiL_OutputParamFilePath);\n",
    "\n",
    "//# \n",
    "(var adata,var data,var namep,var unit,var channel,var description,var convention,var index,var ipx,var Category,var TitleChannel)=getsheetdata(\"WindL\",excle);\n",
    "//# 输出信息\n",
    "file.WriteLine($\"//! 自动生成 WindL 外部风环境模块的有效输出变量数量为:{data.Count}\");\n",
    "//# 写入文件头\n",
    "writeinf(file,\"WindL_OutputParam\");\n",
    "\n",
    "\n",
    "file.WriteLine(\"using System.Collections.Generic;\",\"using System.Collections.Frozen;\",\"using OpenWECD.IO.Log;\",\"using MathNet.Numerics.LinearAlgebra;\",\n",
    "   \"using OpenWECD.IO.Interface1;\");\n",
    "\n",
    "//#写入命名空间\n",
    "file.WriteLine(\"namespace OpenWECD.WindL\");\n",
    "file.WriteLine(\"{\");\n",
    "writesummary(file,\"MBD输出参数类\");\n",
    "file.WriteLine(\"    public class WindL_OutputParam\");\n",
    "file.WriteLine(\"    {\");\n",
    "\n",
    "\n",
    "//! 写入输出参数的单位参数表\n",
    "writesummary(file,\"输出参数的参数表,用来保存变量和单位信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, string> WND_OutParUnit = new Dictionary<string, string>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, unit[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "//# 输出参数的通道表,用来保存变量和通道信息\n",
    "writesummary(file,\"输出参数的通道表,用来保存变量和通道信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> WND_OutParChannel = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, channel[i].ToString(), 10);\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "\n",
    "//# 输出参数的描述表,用来保存变量和描述信息\n",
    "writesummary(file,\"输出参数的维度 0 表示没有维度 1 表示只要部件编号 2 表示只要部件截面 3 表示部件编号和截面编号都要\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> WND_OutParDim = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    if(index[i]==string.Empty)\n",
    "    {\n",
    "        file.Write(\"0\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[Z]\")\n",
    "    {\n",
    "        file.Write(\"1\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[Y]\")\n",
    "    {\n",
    "        file.Write(\"2\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[Y,Z]\")\n",
    "    {\n",
    "        file.Write(\"3\",\"\");\n",
    "    }\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "writesummary(file,\"依据变量名称,输出变量值\");\n",
    "file.WriteLine(\"        public static double WND_GetParamOutput(string param, int Y, WND_AllOuts AllOuts,int Z=0)\");\n",
    "file.WriteLine(\"        {\");\n",
    "file.WriteLine(\"            switch (param)\");\n",
    "file.WriteLine(\"            {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"                case \",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file,data[i],10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.WriteLine(\":\");\n",
    "    file.Write(\"                    return AllOuts.\",\"\");\n",
    "    file.Write(namep[i],\"\");\n",
    "    file.Write(index[i],\"\");\n",
    "    file.WriteLine(\";\");\n",
    "\n",
    "\n",
    "}\n",
    "    file.WriteLine(\"\");\n",
    "    file.WriteLine(\"                default:\");\n",
    "    file.WriteLine(\"                    LogHelper.ErrorLog($\\\"{param} not Support!,Please Visit OutputParList or www.openwecd.fun \\\",FunctionName: \\\"MBD_GetParamOutput\\\");\");\n",
    "    file.WriteLine(\"                    return 0;\");\n",
    "file.WriteLine(\"            }\");\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "\n",
    "//# 输出变量结构体\n",
    "writesummary(file,\"阐述变量的结构体\");\n",
    "file.WriteLine(\"        public struct WND_AllOutss\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.WriteLine(\"            /// <summary>\");\n",
    "    file.WriteLine($\"            /// {description[i]}  {convention[i]}\"+$\" unit:{unit[i]}\");\n",
    "    file.WriteLine(\"            /// </summary>\");\n",
    "        file.Write(\"            public double \",\"\");\n",
    "        file.Write(ipx[i]+\" \",\"\");\n",
    "        file.Write(data[i],\"\");\n",
    "        file.WriteLine(\";\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "//# 输出频道枚举\n",
    "writesummary(file,\"载荷输出的通道枚举体,要和c#自动化文件对应\");\n",
    "file.WriteLine(\"        [SourceReflection]\");\n",
    "file.WriteLine(\"        public enum WND_Loadchannels\");\n",
    "file.WriteLine(\"        {\");\n",
    "for(int i=0;i<Category.Count;i++)\n",
    "{\n",
    "    file.WriteLine($\"            {Category[i]} = {TitleChannel[i]},\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "\n",
    "file.Outfinish(); "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.10 HydroL 模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "LogHelper.DisplayInformation();\n",
    "//# 设置代码路径\n",
    "string ApiL_OutputParamFilePath=@\"G:\\2026\\HawtC2\\modules\\HydroL\\HydroL_OutputParam.cs\";\n",
    "\n",
    "//# 获取对应表格数据\n",
    "var sheet=excle.GetSheet(\"HydroL\");\n",
    "//# 初始化文件读写生成器\n",
    "var file=new OpenWECD.IO.IO.OutFile(ApiL_OutputParamFilePath);\n",
    "\n",
    "//# \n",
    "(var adata,var data,var namep,var unit,var channel,var description,var convention,var index,var ipx,var Category,var TitleChannel,var TitlechannelDisp)=getsheetdata(\"HydroL\",excle);\n",
    "//# 输出信息\n",
    "file.WriteLine($\"//! 自动生成 HydroL 水动力输出变量数量为:{data.Count}\");\n",
    "//# 写入文件头\n",
    "writeinf(file,\"HydroL_OutputParam\");\n",
    "\n",
    "file.WriteLine();\n",
    "file.WriteLine(\"using System.Collections.Generic;\",\"using System.Collections.Frozen;\",\"using OpenWECD.IO.Log;\",\"using MathNet.Numerics.LinearAlgebra;\",\n",
    "   \"using OpenWECD.IO.Interface1;\",\"using SourceGeneration.Reflection;\");\n",
    "\n",
    "//#写入命名空间\n",
    "file.WriteLine(\"namespace OpenWECD.HydroL\");\n",
    "file.WriteLine(\"{\");\n",
    "writesummary(file,\"MBD输出参数类\");\n",
    "file.WriteLine(\"    public class HydroL_OutputParam\");\n",
    "file.WriteLine(\"    {\");\n",
    "\n",
    "\n",
    "//! 写入输出参数的单位参数表\n",
    "writesummary(file,\"输出参数的参数表,用来保存变量和单位信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, string> HYD_OutParUnit = new Dictionary<string, string>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, unit[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "//# 输出参数的通道表,用来保存变量和通道信息\n",
    "writesummary(file,\"输出参数的通道表,用来保存变量和通道信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> HYD_OutParChannel = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, channel[i].ToString(), 10);\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "\n",
    "//# 输出参数的描述表,用来保存变量和描述信息\n",
    "writesummary(file,\"输出参数的维度 0 表示没有维度 1 表示只要部件编号 2 表示只要部件截面 3 表示部件编号和截面编号都要\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> HYD_OutParDim = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "   if(index[i]==string.Empty)\n",
    "    {\n",
    "        file.Write(\"0\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[K]\")\n",
    "    {\n",
    "        file.Write(\"1\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J]\")\n",
    "    {\n",
    "        file.Write(\"2\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J,K]\")\n",
    "    {\n",
    "        file.Write(\"3\",\"\");\n",
    "    }\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "writesummary(file,\"依据变量名称,输出变量值\");\n",
    "file.WriteLine(\"        public static double HYD_GetParamOutput(string param, int J, HYD_AllOuts AllOuts,int K=0)\");\n",
    "file.WriteLine(\"        {\");\n",
    "file.WriteLine(\"            switch (param)\");\n",
    "file.WriteLine(\"            {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"                case \",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file,data[i],10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.WriteLine(\":\");\n",
    "    file.Write(\"                    return AllOuts.\",\"\");\n",
    "    file.Write(namep[i],\"\");\n",
    "    file.Write(index[i],\"\");\n",
    "    file.WriteLine(\";\");\n",
    "\n",
    "\n",
    "}\n",
    "    file.WriteLine(\"\");\n",
    "    file.WriteLine(\"                default:\");\n",
    "    file.WriteLine(\"                    LogHelper.ErrorLog($\\\"{param} not Support!,Please Visit OutputParList or www.openwecd.fun \\\",FunctionName: \\\"MBD_GetParamOutput\\\");\");\n",
    "    file.WriteLine(\"                    return 0;\");\n",
    "file.WriteLine(\"            }\");\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "\n",
    "//# 输出变量结构体\n",
    "writesummary(file,\"阐述变量的结构体\");\n",
    "file.WriteLine(\"        public struct HYD_AllOutss\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.WriteLine(\"            /// <summary>\");\n",
    "    file.WriteLine($\"            /// {description[i]}  {convention[i]}\"+$\" unit:{unit[i]}\");\n",
    "    file.WriteLine(\"            /// </summary>\");\n",
    "        file.Write(\"            public double \",\"\");\n",
    "        file.Write(ipx[i]+\" \",\"\");\n",
    "        file.Write(data[i],\"\");\n",
    "        file.WriteLine(\";\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "//# 输出频道枚举\n",
    "writesummary(file,\"载荷输出的通道枚举体,要和c#自动化文件对应\");\n",
    "file.WriteLine(\"        [SourceReflection]\");\n",
    "file.WriteLine(\"        public enum HYD_Loadchannels\");\n",
    "file.WriteLine(\"        {\");\n",
    "for(int i=0;i<Category.Count;i++)\n",
    "{\n",
    "    file.WriteLine($\"            {Category[i]} = {TitleChannel[i]},\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "file.Outfinish(); \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.11 MSA 模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "OpenWECD.Microsoft.DotNet.Interactive.App - Tel:13935201274  E:1821216780@qq.com http://www.hawtc.cn/\n",
      "************************************************************************************\n",
      "Microsoft.DotNet.Interactive.App Vision:VVSCODE CALL_Release_x64,BuildAt: TESTMODE MathACC:SIMD_by赵子祯\n",
      " > Publish: The Microsoft.DotNet.Interactive.App powered by Tg Team in China,and written by zzz@Copyrigth \n",
      " > Licensd: 超级用户 - Copyright (c)ZHAO ZIZHEN Lic at 2025-02-25 \n"
     ]
    }
   ],
   "source": [
    "LogHelper.DisplayInformation();\n",
    "//# 设置代码路径\n",
    "string ApiL_OutputParamFilePath=@\"G:\\2026\\HawtC2\\modules\\MSAL\\MSA_OutputParam.cs\";\n",
    "\n",
    "//# 获取对应表格数据\n",
    "var sheet=excle.GetSheet(\"MSA\");\n",
    "//# 初始化文件读写生成器\n",
    "var file=new OpenWECD.IO.IO.OutFile(ApiL_OutputParamFilePath);\n",
    "\n",
    "//# \n",
    "(var adata,var data,var namep,var unit,var channel,var description,var convention,var index,var ipx,var Category,var TitleChannel,var TitlechannelDisp)=getsheetdata(\"MSA\",excle);\n",
    "//# 输出信息\n",
    "file.WriteLine($\"//! 自动生成 MSA 模型线性化与稳定求解器的有效输出变量数量为:{data.Count}\");\n",
    "//# 写入文件头\n",
    "writeinf(file,\"MSA\");\n",
    "\n",
    "\n",
    "file.WriteLine(\"using System.Collections.Generic;\",\"using System.Collections.Frozen;\",\"using OpenWECD.IO.Log;\",\"using MathNet.Numerics.LinearAlgebra;\",\n",
    "   \"using OpenWECD.IO.Interface1;\");\n",
    "\n",
    "//#写入命名空间\n",
    "file.WriteLine(\"namespace OpenWECD.MSAL\");\n",
    "file.WriteLine(\"{\");\n",
    "writesummary(file,\"MSA输出参数类\");\n",
    "file.WriteLine(\"    public class MSA_OutputParam\");\n",
    "file.WriteLine(\"    {\");\n",
    "\n",
    "\n",
    "//! 写入输出参数的单位参数表\n",
    "writesummary(file,\"输出参数的参数表,用来保存变量和单位信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, string> MSA_OutParUnit = new Dictionary<string, string>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, unit[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "//# 输出参数的通道表,用来保存变量和通道信息\n",
    "writesummary(file,\"输出参数的通道表,用来保存变量和通道信息\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> MSA_OutParChannel = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, channel[i].ToString(), 10);\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "\n",
    "//# 输出参数的描述表,用来保存变量和描述信息\n",
    "writesummary(file,\"输出参数的维度 0 表示没有维度 1 表示只要部件编号 2 表示只要部件截面 3 表示部件编号和截面编号都要\");\n",
    "file.WriteLine(\"        public static FrozenDictionary<string, int> MSA_OutParDim = new Dictionary<string, int>()\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"            \",\"\");\n",
    "    file.Write(\"{\",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file, data[i], 10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    if(index[i]==string.Empty)\n",
    "    {\n",
    "        file.Write(\"0\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[K]\")\n",
    "    {\n",
    "        file.Write(\"1\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J]\")\n",
    "    {\n",
    "        file.Write(\"2\",\"\");\n",
    "    }\n",
    "    if(index[i]==\"[J,K]\")\n",
    "    {\n",
    "        file.Write(\"3\",\"\");\n",
    "    }\n",
    "    //file.Write(\"\\\"\",\"\");\n",
    "    file.Write(\"}\",\"\");\n",
    "    file.Write(\",\",\"\");\n",
    "\n",
    "    if (i % 4 == 0)\n",
    "    {\n",
    "        file.Write(\"\\n\",\"\");\n",
    "    }\n",
    "}\n",
    "file.WriteLine(\"        }.ToFrozenDictionary();\");\n",
    "\n",
    "writesummary(file,\"依据变量名称,输出变量值\");\n",
    "file.WriteLine(\"        public static double MSA_GetParamOutput(string param, int J, MSA_AllOuts AllOuts,int K=0)\");\n",
    "file.WriteLine(\"        {\");\n",
    "file.WriteLine(\"            switch (param)\");\n",
    "file.WriteLine(\"            {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.Write(\"                case \",\"\");\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    writeo(file,data[i],10);\n",
    "    file.Write(\"\\\"\",\"\");\n",
    "    file.WriteLine(\":\");\n",
    "    file.Write(\"                    return AllOuts.\",\"\");\n",
    "    file.Write(namep[i],\"\");\n",
    "    file.Write(index[i],\"\");\n",
    "    file.WriteLine(\";\");\n",
    "\n",
    "\n",
    "}\n",
    "    file.WriteLine(\"\");\n",
    "    file.WriteLine(\"                default:\");\n",
    "    file.WriteLine(\"                    LogHelper.ErrorLog($\\\"{param} not Support!,Please Visit OutputParList or www.openwecd.fun \\\",FunctionName: \\\"MSA_GetParamOutput\\\");\");\n",
    "    file.WriteLine(\"                    return 0;\");\n",
    "file.WriteLine(\"            }\");\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "\n",
    "//# 输出变量结构体\n",
    "writesummary(file,\"阐述变量的结构体\");\n",
    "file.WriteLine(\"        public struct MSA_AllOutss\");\n",
    "file.WriteLine(\"        {\");\n",
    "for (int i = 0; i < unit.Count; i++)\n",
    "{\n",
    "    file.WriteLine(\"            /// <summary>\");\n",
    "    file.WriteLine($\"            /// {description[i]}  {convention[i]}\"+$\" unit:{unit[i]}\");\n",
    "    file.WriteLine(\"            /// </summary>\");\n",
    "        file.Write(\"            public double \",\"\");\n",
    "        file.Write(ipx[i]+\" \",\"\");\n",
    "        file.Write(data[i],\"\");\n",
    "        file.WriteLine(\";\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "\n",
    "\n",
    "//# 输出初始化变量\n",
    "\n",
    "\n",
    "\n",
    "//# 输出频道枚举\n",
    "writesummary(file,\"载荷输出的通道枚举体,要和c#自动化文件对应\");\n",
    "file.WriteLine(\"        [SourceReflection]\");\n",
    "file.WriteLine(\"        public enum MSA_Loadchannels\");\n",
    "file.WriteLine(\"        {\");\n",
    "for(int i=0;i<Category.Count;i++)\n",
    "{\n",
    "    file.WriteLine(\"            /// <summary>\");\n",
    "    file.WriteLine($\"            /// {TitlechannelDisp[i]}\");\n",
    "    file.WriteLine(\"            /// </summary>\");\n",
    "    file.WriteLine($\"            {Category[i]} = {TitleChannel[i]},\");\n",
    "}\n",
    "file.WriteLine(\"        }\");\n",
    "\n",
    "file.WriteLine(\"    }\");\n",
    "file.WriteLine(\"}\");\n",
    "\n",
    "file.Outfinish(); "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    }
   },
   "outputs": [],
   "source": [
    "TitlechannelDisp"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "languageName": "csharp",
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
